---
title: "Rulemaking Speed in the U.S. States"
output: html_document
date: "2023-05-22"
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
if (!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse, haven, ggplot2, ggmosaic, stargazer, vcd, janitor, flextable, huxtable,captioner, kableExtra, texreg, arsenal, DescTools, lmtest, sandwich, jtools, ggpubr, MASS, broom, AER, survival, survminer, gsheet, sensemakr ) 

df <- read.csv("rule_timing.csv")

```

This file creates the basic versions of all tables and figures from the paper. The underlying `.Rmd` includes the code needed to take the data (found in this dataverse as `rule_timing.csv`) and produce the tables and figures.

### Means for Table 1 

```{r, echo=TRUE, results='asis'}
df %>% filter(legoversight==4 & execveto==0) %>% pull(timetoadoption) %>% mean(na.rm=T) 
df %>% filter(legoversight==3 & execveto==0) %>% pull(timetoadoption) %>% mean(na.rm=T) 
df %>% filter(legoversight==2 & execveto==0) %>% pull(timetoadoption) %>% mean(na.rm=T) 
df %>% filter(legoversight==1 & execveto==0) %>% pull(timetoadoption) %>% mean(na.rm=T)

df %>% filter(legoversight==4 & execveto==1) %>% pull(timetoadoption) %>% mean(na.rm=T) 
df %>% filter(legoversight==3 & execveto==1) %>% pull(timetoadoption) %>% mean(na.rm=T) 
df %>% filter(legoversight==2 & execveto==1) %>% pull(timetoadoption) %>% mean(na.rm=T) 
df %>% filter(legoversight==1 & execveto==1) %>% pull(timetoadoption) %>% mean(na.rm=T)

```

### Table 2

```{r, echo=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption  + gsp_pc + 
           factor(adoptionyear) + factor(Region) , 
         data=.) -> mod1 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) , 
         data=.) -> mod2

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount +  gsp_pc + factor(adoptionyear) + factor(majortopic1FE) + factor(Region), 
         data=.) -> mod3 

fits <- list(mod1, mod2, mod3)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department of Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod1, vcovCL(mod1, type='HC1', cluster=~state)),
            coeftest(mod2, vcovCL(mod2, type='HC1', cluster=~state)),
            coeftest(mod3, vcovCL(mod3, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
            "N" = c(sapply(fits,function(x) glance(x)$nobs)),
            "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Major Topic Fixed Effects" = c("--", "--", "yes"), 
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("1", "2", "3"),
       caption = "",
       table=FALSE,
       digits = 5)

```

### Table B1

```{r, echo=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov  + 
           cw_median  + neighbor_timetoadoption  + gsp_pc + factor(adoptionyear) + factor(Region) , 
         data=.) -> mod1_pars

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov  + 
           cw_median  + neighbor_timetoadoption    + gsp_pc + factor(adoptionyear) + factor(Region) , 
         data=.) -> mod2_pars 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cw_median   + neighbor_timetoadoption   +  gsp_pc + factor(adoptionyear) + factor(majortopic1FE) + 
           factor(Region), 
         data=.) -> mod3_pars

fits <- list(mod1_pars, mod2_pars, mod3_pars)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "gsp_pc" = "Gross State Product, per capita",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod1_pars, vcovCL(mod1, type='HC1', cluster=~state)),
            coeftest(mod2_pars, vcovCL(mod2, type='HC1', cluster=~state)),
            coeftest(mod3_pars, vcovCL(mod3, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
            "N" = c(sapply(fits,function(x) glance(x)$nobs)),
            "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Major Topic Fixed Effects" = c("--", "--", "yes"), 
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("1", "2", "3"),
       caption = "",
       table=FALSE,
       digits = 5)
```

### Table C1

```{r, echo=FALSE, results='asis'}

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + ri + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption  + gsp_pc + 
           factor(adoptionyear) + factor(Region) , 
         data=.) -> mod1

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + ri + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) , 
         data=.) -> mod2

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + ri + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount +  gsp_pc + factor(adoptionyear) + factor(majortopic1FE) + factor(Region), 
         data=.) -> mod3

fits <- list(mod1, mod2, mod3)

coefs = list(
             "ri" = "Rulemaking Restrictiveness Index (Renfrow, West, and Houston 1986)",
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department of Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod1, vcovCL(mod1, type='HC1', cluster=~state)),
            coeftest(mod2, vcovCL(mod2, type='HC1', cluster=~state)),
            coeftest(mod3, vcovCL(mod3, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
            "N" = c(sapply(fits,function(x) glance(x)$nobs)),
            "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Major Topic Fixed Effects" = c("--", "--", "yes"), 
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("1", "2", "3"),
       caption = "",
       table=FALSE,
       digits = 5)

```

Tables D1 and D2 


```{stata, eval=FALSE}

import delimited using "for_eha"


destring citationcount, generate(citationcount1) force
destring majortopic1fe, generate(majortopic1fe1) force
destring squire_prof, generate(squire_prof1) force
destring execsalary_fromfwd_nogov, generate(execsalary_fromfwd_nogov1) force
destring legoversight, generate(legoversight1) force
destring execveto, generate(execveto1) force
destring divided_gov, generate(divided_gov1) force
destring adoptedrules_ner, generate(adoptedrules_ner1) force
destring cw_median, generate(cw_median1) force
destring neighbor_timetoadoption, generate(neighbor_timetoadoption1) force
replace legoversight1=3 if legoversight1>2 & legoversight1<3


stset time, failure(failed==1) id(id)


/* Table */
stcox squire_prof1 execsalary_fromfwd_nogov1 i.legoversight1 execveto1 divided_gov1 adoptedrules_ner1 cw_median1 cumulative_rules org_dept_agency neighbor_timetoadoption1,  nohr nolog  robust
stcox squire_prof1 execsalary_fromfwd_nogov1 i.legoversight1 execveto1 divided_gov1 adoptedrules_ner1 cw_median1 cumulative_rules org_dept_agency neighbor_timetoadoption1 hearingcount citationcount1,  nohr nolog  robust
stcox squire_prof1 execsalary_fromfwd_nogov1 i.legoversight1 execveto1 divided_gov1 adoptedrules_ner1 cw_median1 cumulative_rules org_dept_agency neighbor_timetoadoption1 hearingcount citationcount1,  nohr nolog strata(majortopic1fe1) robust

drop if ever_adopted==0

/* Table */
stcox squire_prof1 execsalary_fromfwd_nogov1 i.legoversight1 execveto1 divided_gov1 adoptedrules_ner1 cw_median1 cumulative_rules org_dept_agency neighbor_timetoadoption1,  nohr nolog  robust
stcox squire_prof1 execsalary_fromfwd_nogov1 i.legoversight1 execveto1 divided_gov1 adoptedrules_ner1 cw_median1 cumulative_rules org_dept_agency neighbor_timetoadoption1 hearingcount citationcount1,  nohr nolog  robust
stcox squire_prof1 execsalary_fromfwd_nogov1 i.legoversight1 execveto1 divided_gov1 adoptedrules_ner1 cw_median1 cumulative_rules org_dept_agency neighbor_timetoadoption1 hearingcount citationcount1,  nohr nolog strata(majortopic1fe1) robust

```


### Table F1

```{r, echo=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight)*execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + gsp_pc + 
           factor(adoptionyear) + factor(Region) , 
         data=.) -> mod4

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight)*execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount +  gsp_pc + factor(adoptionyear) + factor(Region) , 
         data=.) -> mod5

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight)*execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount +  gsp_pc + factor(adoptionyear) + factor(majortopic1FE) + factor(Region), 
         data=.) -> mod6

fits <- list(mod4, mod5, mod6)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",             
             "execveto" = "Executive Veto",
             "factor(legoversight)2:execveto" = "Suspension Oversight x Executive Veto",
             "factor(legoversight)3:execveto" = "Hybrid Oversight x Executive Veto",
             "factor(legoversight)4:execveto" = "No Oversight x Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department of Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod4, vcovCL(mod4, type='HC1', cluster=~state)),
            coeftest(mod5, vcovCL(mod5, type='HC1', cluster=~state)),
            coeftest(mod6, vcovCL(mod6, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
            "N" = c(sapply(fits,function(x) glance(x)$nobs)),
            "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Major Topic Fixed Effects" = c("--", "--", "yes"), 
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("1", "2", "3"),
       caption = "",
       table=FALSE,
       digits = 5)

```


### Table E1 

```{r, echo=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + pm_expend + pm_t_slength + legsal2_fwd + 
           execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + 
           neighbor_timetoadoption  + gsp_pc + factor(adoptionyear) + factor(Region) , 
         data=.) -> mod1 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + pm_expend + pm_t_slength + legsal2_fwd + 
           execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + 
           neighbor_timetoadoption + citationcount + hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) , 
         data=.) -> mod2

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + pm_expend + pm_t_slength + legsal2_fwd + 
           execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + 
           neighbor_timetoadoption + citationcount + hearingcount +  gsp_pc + factor(adoptionyear) + 
           factor(majortopic1FE) + factor(Region), 
         data=.) -> mod3

coefs = list(
             #"squire_prof" = "Legislative Professionalism (Squire Index)",
             "pm_expend" = "Legislative Expenditures, per legislator",
             "pm_t_slength" = "Legislative Session Length",
             "legsal2_fwd" = "Legislative Salary (adj. by COL and CPI, thousands of dollars)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department of Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod1, vcovCL(mod1, type='HC1', cluster=~state)),
            coeftest(mod2, vcovCL(mod2, type='HC1', cluster=~state)),
            coeftest(mod3, vcovCL(mod3, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
            "N" = c(sapply(fits,function(x) glance(x)$nobs)),
            "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Major Topic Fixed Effects" = c("--", "--", "yes"), 
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("1", "2", "3"),
       caption = "",
       table=FALSE,
       digits = 5)
```

### Table E2

```{r, echo=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + pm_expend + pm_t_slength + differencesal_NOgov + divided_gov
         + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption  + gsp_pc +
           factor(adoptionyear) + factor(Region), 
         data=.) -> mod1 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + pm_expend + pm_t_slength + differencesal_NOgov + divided_gov
         + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount +
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) , 
         data=.) -> mod2 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + pm_expend + pm_t_slength + differencesal_NOgov + divided_gov
         + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount +
           hearingcount +  gsp_pc + factor(adoptionyear) + factor(majortopic1FE) + factor(Region), 
         data=.) -> mod3 

fits <- list(mod1, mod2, mod3)

coefs = list(
             #"squire_prof" = "Legislative Professionalism (Squire Index)",
             "pm_expend" = "Legislative Expenditures, per legislator",
             "pm_t_slength" = "Legislative Session Length",
             #"legsal2_fwd" = "Legislative Salary (adj. by COL and CPI, thousands of dollars)",
             #"execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "differencesal_NOgov" = "Difference in Salary B/t Executive and Legislative (in thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department of Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod1, vcovCL(mod1, type='HC1', cluster=~state)),
            coeftest(mod2, vcovCL(mod2, type='HC1', cluster=~state)),
            coeftest(mod3, vcovCL(mod3, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
            "N" = c(sapply(fits,function(x) glance(x)$nobs)),
            "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Major Topic Fixed Effects" = c("--", "--", "yes"), 
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("1", "2", "3"),
       caption="",
       table=FALSE,
       digits = 5)
```


### Table G1

```{r, echo=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas" & !is.na(execveto)) %>% 
  glm.nb(timetoadoption ~  squire_prof + execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + 
           adoptedrules_NER + org_dept_agency + neighbor_timetoadoption  + gsp_pc + factor(adoptionyear) + factor(fips) ,
         data=.) -> mod1 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas" & !is.na(execveto)) %>% 
  glm.nb(timetoadoption ~  squire_prof + execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + 
         adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount  + gsp_pc +                  factor(adoptionyear) + factor(fips), 
         data=.) -> mod2 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas" & !is.na(execveto)) %>% 
  glm.nb(timetoadoption ~   squire_prof + execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + 
           adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount +  gsp_pc +                  factor(adoptionyear) +  factor(fips) + factor(majortopic1FE), 
         data=.) -> mod3 

fits <- list(mod1, mod2, mod3)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             #"factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             #"factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             #"factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             #"execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department of Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod1, vcovCL(mod1, type='HC1', cluster=~state)),
            coeftest(mod2, vcovCL(mod2, type='HC1', cluster=~state)),
            coeftest(mod3, vcovCL(mod3, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
            "N" = c(sapply(fits,function(x) glance(x)$nobs)),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "State Fixed Effects" = c("yes", "yes", "yes"),
            "Major Topic Fixed Effects" = c("--", "--", "yes"), 
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("1", "2", "3"),
       caption = "",
       table=FALSE,
       digits = 5)
```

### Table G2

```{r, echo=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~  pm_expend + pm_t_slength + legsal2_fwd + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption  + gsp_pc + 
           factor(adoptionyear) + factor(fips) , 
         data=.) -> mod1

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~  pm_expend + pm_t_slength + legsal2_fwd + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(fips), 
         data=.) -> mod2 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~   pm_expend + pm_t_slength + legsal2_fwd + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount +  gsp_pc + factor(adoptionyear) + + factor(fips) + factor(majortopic1FE), 
         data=.) -> mod3

fits <- list(mod1, mod2, mod3)

coefs = list(
             "pm_expend" = "Legislative Expenditures, per legislator",
             "pm_t_slength" = "Legislative Session Length",
             "legsal2_fwd" = "Legislative Salary (adj. by COL and CPI, thousands of dollars)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             #"factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             #"factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             #"factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             #"execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department of Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod1, vcovCL(mod1, type='HC1', cluster=~state)),
            coeftest(mod2, vcovCL(mod2, type='HC1', cluster=~state)),
            coeftest(mod3, vcovCL(mod3, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
            "N" = c(sapply(fits,function(x) glance(x)$nobs)),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "State Fixed Effects" = c("yes", "yes", "yes"),
            "Major Topic Fixed Effects" = c("--", "--", "yes"), 
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("1", "2", "3"),
       caption = "",
       table=FALSE,
       digits = 5)
```

### Table G3

```{r, echo=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~  pm_expend + pm_t_slength + differencesal_NOgov + divided_gov + cumulative_rules + cw_median + 
           adoptedrules_NER + org_dept_agency + neighbor_timetoadoption  + gsp_pc + factor(adoptionyear) + factor(fips) ,
         data=.) -> mod1

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~  pm_expend + pm_t_slength + differencesal_NOgov + divided_gov + cumulative_rules + cw_median + 
           adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount  + gsp_pc +                  factor(adoptionyear) + factor(fips), 
         data=.) -> mod2 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~   pm_expend + pm_t_slength + differencesal_NOgov + divided_gov + cumulative_rules + cw_median +         adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount +  gsp_pc +                  factor(adoptionyear) + + factor(fips) + factor(majortopic1FE), 
         data=.) -> mod3 

fits <- list(mod1, mod2, mod3)

coefs = list(
             "pm_expend" = "Legislative Expenditures, per legislator",
             "pm_t_slength" = "Legislative Session Length",
             #"legsal2_fwd" = "Legislative Salary (adj. by COL and CPI, thousands of dollars)",
             #"execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             #"factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             #"factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             #"factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             #"execveto" = "Executive Veto",
             "differencesal_NOgov" = "Difference in Salary B/t Executive and Legislative (in thousands of dollars)",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department of Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod1, vcovCL(mod1, type='HC1', cluster=~state)),
            coeftest(mod2, vcovCL(mod2, type='HC1', cluster=~state)),
            coeftest(mod3, vcovCL(mod3, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
            "N" = c(sapply(fits,function(x) glance(x)$nobs)),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "State Fixed Effects" = c("yes", "yes", "yes"),
            "Major Topic Fixed Effects" = c("--", "--", "yes"), 
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("1", "2", "3"),
       caption = "",
       table=FALSE,
       digits = 5)
```


### Appendix H 

```{r, echo=FALSE, warning=FALSE, results='asis'}
df$legoversight <- as.factor(df$legoversight)
df$adoptionyear <- as.factor(df$adoptionyear)
df$majortopic1FE <- as.factor(df$majortopic1FE)
df$Region <- as.factor(df$Region)

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  lm(timetoadoption ~ legoversight + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
       cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
       hearingcount +  gsp_pc + adoptionyear + majortopic1FE + Region, 
         data=.) -> mod

sensitivity.squire <- sensemakr(model = mod, 
                                treatment = "squire_prof",
                                benchmark_covariates = "adoptedrules_NER",
                                kd = 1:3)


sensitivity.nooversight <- sensemakr(model = mod, 
                                treatment = "legoversight4",
                                benchmark_covariates = "adoptedrules_NER",
                                kd = 1:3)


ovb_minimal_reporting(sensitivity.squire, format = "html")
ovb_minimal_reporting(sensitivity.nooversight, format = "html")

plot(sensitivity.squire, type="extreme")

plot(sensitivity.nooversight, type="extreme")
```




### Table I1

```{r, echo=FALSE, warning=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="AGRICULTURE") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + AGRICULTURE   , 
         data=.) -> mod_ag

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="BUSINESS AND CORPORATIONS SPECIFIC INDUSTRIES") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + BUSINESS_AND_CORPORATIONS_SPECIFIC_INDUSTRIES   , 
         data=.) -> mod_biz

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="CHEMICALS") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + CHEMICALS   , 
         data=.) -> mod_chem

fits <- list(mod_ag, mod_biz, mod_chem)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department of Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "AGRICULTURE" = "Agricultural IG Density",
             "BUSINESS_AND_CORPORATIONS_SPECIFIC_INDUSTRIES" = "Business IG Density",
             "CHEMICALS" = "Chemicals IG Density",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod_ag, vcovCL(mod_ag, type='HC1', cluster=~state)),
            coeftest(mod_biz, vcovCL(mod_biz, type='HC1', cluster=~state)),
            coeftest(mod_chem, vcovCL(mod_chem, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
           "N" = c(sapply(fits,function(x) glance(x)$nobs)),
           "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("Agriculture", "Business", "Chemicals"),
       caption = "",
       table=FALSE,
       digits = 5)

```


### Table I2

```{r, echo=FALSE, warning=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="COMMUNICATION AND INFORMATION") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + COMMUNICATION_AND_INFORMATION   , 
         data=.) -> mod_comm 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="CONSUMER AFFAIRS") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + CONSUMER_AFFAIRS   , 
         data=.) -> mod_ca 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="EDUCATION") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + EDUCATION   , 
         data=.) -> mod_educ

fits <- list(mod_comm, mod_ca, mod_educ)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department or Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "COMMUNICATION_AND_INFORMATION" = "Communication and Information IG Density",
             "CONSUMER_AFFAIRS" = "Consumer Affairs IG Density",
             "EDUCATION" = "Education IG Density",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod_comm, vcovCL(mod_comm, type='HC1', cluster=~state)),
            coeftest(mod_ca, vcovCL(mod_ca, type='HC1', cluster=~state)),
            coeftest(mod_educ, vcovCL(mod_educ, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
           "N" = c(sapply(fits,function(x) glance(x)$nobs)),
           "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("Communication and Information", "Consumer Affairs", "Education"),
       caption = "",
       table=FALSE,
       digits = 5)

```


### Table I3

```{r, echo=FALSE, warning=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="ENERGY") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + ENERGY   , 
         data=.) -> mod_en

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="ENVIRONMENTAL ISSUES- MISC") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + ENVIRONMENTAL_ISSUES_MISC   , 
         data=.) -> mod_env

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="FINANCIAL INSTITUTIONS") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + FINANCIAL_INSTITUTIONS   , 
         data=.) -> mod_bank

fits <- list(mod_en, mod_env, mod_bank)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department or Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "ENERGY" = "Energy IG Density",
             "ENVIRONMENTAL_ISSUES_MISC" = "Environmental IG Density",
             "FINANCIAL_INSTITUTIONS" = "Banking IG Density",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod_en, vcovCL(mod_en, type='HC1', cluster=~state)),
            coeftest(mod_env, vcovCL(mod_env, type='HC1', cluster=~state)),
            coeftest(mod_bank, vcovCL(mod_bank, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
           "N" = c(sapply(fits,function(x) glance(x)$nobs)),
           "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("Energy", "Environment", "Banking"),
       caption = "",
       table=FALSE,
       digits = 5)

```


### Table I4

```{r, echo=FALSE, warning=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="FOOD AND BEVERAGES") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + FOOD_AND_BEVERAGES   , 
         data=.) -> mod_food

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="GAS") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + GAS   , 
         data=.) -> mod_gas

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="HEALTH AND SOCIAL SERVICES") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + HEALTH_AND_SOCIAL_SERVICES   , 
         data=.) -> mod_health


fits <- list(mod_food, mod_gas, mod_health)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department or Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "FOOD_AND_BEVERAGES" = "Hospitality IG Density",
             "GAS" = "Gas IG Density",
             "HEALTH_AND_SOCIAL_SERVICES" = "Health and Social Services IG Density",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod_food, vcovCL(mod_food, type='HC1', cluster=~state)),
            coeftest(mod_gas, vcovCL(mod_gas, type='HC1', cluster=~state)),
            coeftest(mod_health, vcovCL(mod_health, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
           "N" = c(sapply(fits,function(x) glance(x)$nobs)),
           "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("Hospitality", "Gas", "Health and Social Services"),
       caption = "",
       table=FALSE,
       digits = 5)

```

### Table I5

```{r, echo=FALSE, warning=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="INSURANCE") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + INSURANCE   , 
         data=.) -> mod_ins 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="LABOR AND EMPLOYMENT") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + LABOR_AND_EMPLOYMENT  , 
         data=.) -> mod_labor

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="LAW AND JUSTICE") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + LAW_AND_JUSTICE   , 
         data=.) -> mod_law 

fits <- list(mod_ins, mod_labor, mod_law)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department or Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "INSURANCE" = "Insurance IG Density",
             "LABOR_AND_EMPLOYMENT" = "Labor IG Density",
             "LAW_AND_JUSTICE" = "Law and Justice IG Density",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod_ins, vcovCL(mod_ins, type='HC1', cluster=~state)),
            coeftest(mod_labor, vcovCL(mod_labor, type='HC1', cluster=~state)),
            coeftest(mod_law, vcovCL(mod_law, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
           "N" = c(sapply(fits,function(x) glance(x)$nobs)),
           "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("Insurance", "Labor", "Law and Justice"),
       caption = "", 
       table=FALSE,
       digits = 5)
```


### Table I6

```{r, echo=FALSE, warning=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="POLITICS AND GOVERNMENT") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + POLITICS_AND_GOVERNMENT   , 
         data=.) -> mod_pg 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="REAL ESTATE AND CONSTRUCTION") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + REALESTATE_AND_CONSTRUCTION  , 
         data=.) -> mod_re

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="RECREATION AND THE ARTS") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + RECREATION_AND_THE_ARTS   , 
         data=.) -> mod_rec

fits <- list(mod_pg, mod_re, mod_rec)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department or Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "POLITICS_AND_GOVERNMENT" = "Politics and Govt IG Density",
             "REALESTATE_AND_CONSTRUCTION" = "Real Estate and Construction IG Density",
             "RECREATION_AND_THE_ARTS" = "Recreation and the Arts IG Density",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod_pg, vcovCL(mod_pg, type='HC1', cluster=~state)),
            coeftest(mod_re, vcovCL(mod_re, type='HC1', cluster=~state)),
            coeftest(mod_rec, vcovCL(mod_rec, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
           "N" = c(sapply(fits,function(x) glance(x)$nobs)),
           "Region Fixed Effects" = c("yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes"),
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("Politics and Govt", "Real Estate and Construction", "Recreation and the Arts"),
       caption = "", 
       table=FALSE,
       digits = 5)
```


### Table I7

```{r, echo=FALSE, warning=FALSE, results='asis'}
df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="RESOURCE MANAGEMENT AND PRESERVATION") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount +            hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + RESOURCE_MANAGEMENT_AND_PRESERVATION   , 
         data=.) -> mod_resou

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="TAXATION") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + TAXATION , 
         data=.) -> mod_tax

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="TRANSPORTATION") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + TRANSPORTATION   , 
         data=.) -> mod_trans 

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>%
    filter(majortopic1=="UTILITIES AND APPLIANCES") %>%
  glm.nb(timetoadoption ~ factor(legoversight) + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount  + gsp_pc + factor(adoptionyear) + factor(Region) + UTILITIES_AND_APPLIANCES   , 
         data=.) -> mod_utils 

fits <- list(mod_resou, mod_tax, mod_trans, mod_utils)

coefs = list(
             "squire_prof" = "Legislative Professionalism (Squire Index)",
             "execsalary_fromfwd_NOgov" = "Executive Salary (adj. by COL and CPI, thousands of dollars)",
             "factor(legoversight)2" = "Suspension Oversight (Relative to Nullification)",
             "factor(legoversight)3" = "Hybrid Oversight (Relative to Nullification)",
             "factor(legoversight)4" = "No Oversight (Relative to Nullification)",
             "execveto" = "Executive Veto",
             "divided_gov" = "Divided Government at Rule Proposal", 
             "adoptedrules_NER" = "Number of Adopted Rules in a Year",
             "cw_median" = "Caughey-Warshaw State Policy Liberalism", 
             "cumulative_rules" = "Total Cumulative Number of Adopted Rules in State/Population",
             "org_dept_agency" = "Issued by a Department or Agency",
             "neighbor_timetoadoption" = "Mean Time to Adoption in Neighbor States",
             "citationcount" = "Sections of State Code Affected by Rule",
             "hearingcount" = "Number of Hearings Held Regarding Rule",
             "gsp_pc" = "Gross State Product, per capita",
             "RESOURCE_MANAGEMENT_AND_PRESERVATION" = "Resources IG Density",
             "TAXATION" = "Taxation IG Density",
             "TRANSPORTATION" = "Transportation IG Density",
             "UTILITIES_AND_APPLIANCES" = "Utilities IG Density",
             "(Intercept)" = "Intercept" 
)

htmlreg(list(coeftest(mod_resou, vcovCL(mod_resou, type='HC1', cluster=~state)),
            coeftest(mod_tax, vcovCL(mod_tax, type='HC1', cluster=~state)),
            coeftest(mod_trans, vcovCL(mod_trans, type='HC1', cluster=~state)),
            coeftest(mod_utils, vcovCL(mod_utils, type='HC1', cluster=~state))),
       custom.coef.map = coefs,
       custom.gof.rows = list(
           "N" = c(sapply(fits,function(x) glance(x)$nobs)),
           "Region Fixed Effects" = c("yes", "yes", "yes", "yes"),
            "Year Fixed Effects" = c("yes", "yes", "yes", "yes"),
            "Overdispersion \\theta" = c(sapply(fits,function(x) summary(x)$theta)),
            "Overdispersion \\alpha" = c(sapply(fits,function(x) 1/summary(x)$theta))
            ),
       custom.model.names = c("Resources", "Taxation", "Transportation", "Utilities"),
       caption = "", 
       table=FALSE,
       digits = 5)
```

### Figure 1


```{r, echo=FALSE, warning=FALSE, results='asis'}
#levels(df$legoversight)

levels(df$legoversight) <- c("Nullification Oversight","Suspension Oversight","Hybrid Oversight",
                            "No Legislative Oversight")

df  %>% filter(!is.na(legoversight)) %>%
ggplot(., aes(x=reorder(state, timetoadoption,fun=median, na.rm=T), y=timetoadoption, fill=legoversight)) + geom_boxplot(outlier.shape = NA)  + coord_flip() + ylim(0, 1000) +
   xlab("State") + ylab("Time to Adoption") + theme(axis.text=element_text(size=12)) + theme(legend.title=element_blank())


```

### Figure 2

```{r, echo=FALSE, warning=FALSE, results='asis'}

#df <- df[!grepl("POLLUTION", df$majortopic1),]
#df <- df[!grepl("SPECIAL", df$majortopic1),]
#df <- df[!(is.na(df$majortopic1) | df$majortopic1==""), ]
df <- df %>% mutate(majortopic1 = ifelse(majortopic1 == "", "Environmental Protection and Pollution Control", majortopic1)) %>% mutate(majortopic1 = ifelse(majortopic1 == "Environmental Protectionand Pollution Control", "Environmental Protection and Pollution Control", majortopic1))

  
  
df$majortopic1 <- tolower(df$majortopic1)

simpleCap <- function(x) {
    s <- strsplit(x, " ")[[1]]
    paste(toupper(substring(s, 1,1)), substring(s, 2),
          sep="", collapse=" ")
}

df$majortopic1 <- sapply(df$majortopic1, simpleCap)

df  %>% filter(!is.na(legoversight)) %>% filter(majortopic1 != "Tv") %>% filter(majortopic1 != "Gas") %>%
  filter(majortopic1 != "Cpr") %>% filter(majortopic1 != "Special Measures") %>% filter(majortopic1 != "Environmental Protectionand Pollution Control") %>% 
ggplot(., aes(x=reorder(majortopic1, timetoadoption,fun=median, na.rm=T), y=timetoadoption, fill=legoversight)) + geom_boxplot(outlier.shape = NA)  + coord_flip() + ylim(0, 500) + 
  xlab("Major Topic") + ylab("Time to Adoption") + theme(axis.text=element_text(size=12)) + theme(legend.title=element_blank())
```

### Figure 3

```{r, echo=FALSE, warning=FALSE, results='asis'}
#df$legoversight <- as.factor(df$legoversight)
#df$adoptionyear <- as.factor(df$adoptionyear)
#df$majortopic1FE <- as.factor(df$majortopic1FE)
#df$Region <- as.factor(df$Region)

df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ legoversight + execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount +  gsp_pc + adoptionyear + majortopic1FE + Region, 
         data=.) -> mod 


names <- NULL
for (i in 1:26) {
  names[i] <- (df %>% filter(majortopic1FE==i) %>% pull(majortopic1))[1]
}

nums <- 1:26

d <- as.data.frame(cbind(names, nums))

archetypal_df <- data.frame(
"legoversight" = "No Legislative Oversight",
"execveto" = 1,
"squire_prof" = mean(df$squire_prof, na.rm=T), 
"execsalary_fromfwd_NOgov" = mean(df$execsalary_fromfwd_NOgov, na.rm = T),
"divided_gov" = 0,
"cumulative_rules" = mean(df$cumulative_rules, na.rm=T),
"cw_median" = mean(df$cw_median, na.rm=T),
"adoptedrules_NER" = mean(df$adoptedrules_NER, na.rm=T),
"org_dept_agency" = 1,
"neighbor_timetoadoption" = mean(df$neighbor_timetoadoption, na.rm=T),
"citationcount" = mean(df$citationcount, na.rm=T),
"hearingcount" = mean(df$hearingcount, na.rm=T),
"gsp_pc" = mean(df$gsp_pc, na.rm=T),
"adoptionyear" = "2001",
"majortopic1FE" = factor(rep(1:26), levels = 1:26, labels = levels(df$majortopic1FE)),
"Region" = "West"

)

#archetypal_df <- archetypal_df  %>% filter(majortopic1FE!=10) %>% filter(majortopic1FE!=22)

#mod %>%
#augment(newdata = archetypal_df,
#type.predict = "response",
#se_fit = TRUE) 

archetypal_df <- cbind(archetypal_df, predict(mod, archetypal_df, type = "link", se.fit=TRUE))

archetypal_df <- within(archetypal_df, {
  Days <- exp(fit)
  LL <- exp(fit - 1.96 * se.fit)
  UL <- exp(fit + 1.96 * se.fit)
})

#d <- d %>% filter(nums!=10) %>% filter(nums!=22) 

d <- as.data.frame(cbind(d, archetypal_df[,22], archetypal_df[,21], archetypal_df[,20] ))
d <- d[, -2]

names(d) <- c("topic", "effect", "lower", "upper")

#d$effect <- log(d$effect)
#d$lower <- log(d$lower)
#d$upper <- log(d$upper)

#d<- d[-23, ] # TV
#d<- d[-6, ] # CPR

# Manual Environment average 
ph1 <- (d[9,2] + d[10,2])/2 # effect
ph2 <- (d[9,3] + d[10,3])/2 # low 
ph3 <- (d[9,4] + d[10,4])/2 # high

d<- d[-c(9),]
d[9,1] <- "Environment"
d[9,2] <- ph1
d[9,3] <- ph2
d[9,4] <- ph3


d$topic <- as.factor(d$topic)
d$topic <- fct_rev(d$topic)


#d$effect <- log(d$effect)
#d$lower <- log(d$lower)
#d$upper <- log(d$upper)


d %>% filter(topic != "Tv") %>% filter(topic != "Cpr") %>%
  ggplot(data = ., aes(x = topic, y = effect, ymin = lower, ymax = upper)) +
    geom_point(position = position_dodge(width = 0.3), , size=2) +
    geom_errorbar(position = position_dodge(width = 0.3), width = 0.2) +
    xlab("") + ylab("Predicted Number of Days") +
    theme(legend.title=element_blank()) + coord_flip() 

```

### Figure F1

```{r, echo=FALSE, warning=FALSE, results='asis'}
df <- read.csv("data.csv")


df %>% 
  filter(state != "Alaska" & state != "Hawaii" & state != "Nebraska" & state != "Texas") %>% 
  glm.nb(timetoadoption ~ factor(legoversight)*execveto + squire_prof + execsalary_fromfwd_NOgov + divided_gov + 
           cumulative_rules + cw_median + adoptedrules_NER + org_dept_agency + neighbor_timetoadoption + citationcount + 
           hearingcount +  gsp_pc + factor(adoptionyear) + factor(Region) , 
         data=.) -> mod5


mfx <- function(beta1, beta3, z, var1, var3, cov13){
  meff <- beta1+beta3*z
  #print(paste("Marginal Effect:", round(meff,4) ))
  se_mfx <- sqrt(var1 + (z^2)*var3 + 2*z*cov13)
  #print(paste("SE:", round(se_mfx,4) ))
  return(nums <- cbind(meff, se_mfx))
}

mod5.vcov <- vcovCL(mod5, type='HC1', cluster=~state)

# EV with Nullification 
ev_null <- mfx(mod5$coefficients["execveto"], 
    0, 
    1, # 1 because z=1 when factor present
    mod5.vcov["execveto","execveto"], 
    0, 
    0 ) 

# EV with Suspension 
ev_sus <- mfx(mod5$coefficients["execveto"], 
    mod5$coefficients["factor(legoversight)2:execveto"], 
    1, # 1 because z=1 when factor present
    mod5.vcov["execveto","execveto"], 
    mod5.vcov["factor(legoversight)2:execveto","factor(legoversight)2:execveto"], 
    mod5.vcov["execveto","factor(legoversight)2:execveto"]  ) 

# EV with Hybrid 
ev_hybrid <-  mfx(mod5$coefficients["execveto"], 
    mod5$coefficients["factor(legoversight)3:execveto"], 
    1, # 1 because z=1 when factor present
    mod5.vcov["execveto","execveto"], 
    mod5.vcov["factor(legoversight)3:execveto","factor(legoversight)3:execveto"], 
    mod5.vcov["execveto","factor(legoversight)3:execveto"]  ) 

# EV with No Oversight
ev_no <- mfx(mod5$coefficients["execveto"], 
    mod5$coefficients["factor(legoversight)4:execveto"], 
    1, # 1 because z=1 when factor present
    mod5.vcov["execveto","execveto"], 
    mod5.vcov["factor(legoversight)4:execveto","factor(legoversight)4:execveto"], 
    mod5.vcov["execveto","factor(legoversight)4:execveto"]  ) 

######################################

# Suspension with EV 

sus_yes <- mfx(mod5$coefficients["factor(legoversight)2"], 
    mod5$coefficients["factor(legoversight)2:execveto"], 
    1, # 1 because z=1 when factor present
    mod5.vcov["factor(legoversight)2","factor(legoversight)2"], 
    mod5.vcov["factor(legoversight)2:execveto","factor(legoversight)2:execveto"], 
    mod5.vcov["factor(legoversight)2","factor(legoversight)2:execveto"]  ) 

# Suspension with no EV 

sus_no <- mfx(mod5$coefficients["factor(legoversight)2"], 
    0, 
    1, # 1 because z=1 when factor present
    mod5.vcov["factor(legoversight)2","factor(legoversight)2"], 
    0, 
    0  ) 



######################################

# Hybrid with EV 

hybrid_yes <- mfx(mod5$coefficients["factor(legoversight)3"], 
    mod5$coefficients["factor(legoversight)3:execveto"], 
    1, # 1 because z=1 when factor present
    mod5.vcov["factor(legoversight)3","factor(legoversight)3"], 
    mod5.vcov["factor(legoversight)3:execveto","factor(legoversight)3:execveto"], 
    mod5.vcov["factor(legoversight)3","factor(legoversight)3:execveto"]  ) 

# Hybrid with no EV 

hybrid_no <- mfx(mod5$coefficients["factor(legoversight)3"], 
    0, 
    1, # 1 because z=1 when factor present
    mod5.vcov["factor(legoversight)3","factor(legoversight)3"], 
    0, 
    0  )

######################################

# No Oversight with EV 

none_yes <- mfx(mod5$coefficients["factor(legoversight)4"], 
    mod5$coefficients["factor(legoversight)4:execveto"], 
    1, # 1 because z=1 when factor present
    mod5.vcov["factor(legoversight)4","factor(legoversight)4"], 
    mod5.vcov["factor(legoversight)4:execveto","factor(legoversight)4:execveto"], 
    mod5.vcov["factor(legoversight)4","factor(legoversight)4:execveto"]  ) 

# No Oversight with no EV 

none_no <- mfx(mod5$coefficients["factor(legoversight)4"], 
    0, 
    1, # 1 because z=1 when factor present
    mod5.vcov["factor(legoversight)4","factor(legoversight)4"], 
    0, 
    0  )

forplot <- rbind(ev_null,ev_sus, ev_hybrid, ev_no, sus_yes, sus_no, hybrid_yes, hybrid_no, none_yes, none_no )

coef.vec <- forplot[,1]
se.vec <- forplot[,2]

var.names <- c("Effect of Executive Veto with Nullification Oversight",
               "Effect of Executive Veto with Suspension Oversight",
               "Effect of Executive Veto with Hybrid Oversight",
               "Effect of Executive Veto with No Oversight",
               "Effect of Suspension Oversight with Executive Veto",
               "Effect of Suspension Oversight with No Executive Veto",
               "Effect of Hybrid Oversight with Executive Veto",
               "Effect of Hybrid Oversight with No Executive Veto",
               "Effect of No Oversight with Executive Veto",
               "Effect of No Oversight with No Executive Veto"
               )

y.axis <- c(length(coef.vec):1)
adjust <- .15 

par(mar=c(2, 25, 2, 1))
plot(coef.vec, y.axis, type = "p", axes = F, xlab = "", ylab = "", pch = 19, cex = 2.5,
     xlim = c(-1.5,1.5), xaxs = "r", main = "Marginal Effects, with 95 Percent Confidence Intervals")
segments(coef.vec-qnorm(.95)*se.vec, y.axis, coef.vec + qnorm(.95)*se.vec, y.axis, lwd =  1.5)
axis(1, at = seq(-1.5,1.5,by=.5), labels = NA, tick = T,
     cex.axis = 1.2)
axis(1, at = seq(-1.5,1.5,by=.5), labels =  c(-1.5,-1,-.5,  0,.5, 1,1.5), tick = T,
     cex.axis = 1.2)
axis(2, at = y.axis, label = var.names, las = 1, tick = F, ,mgp = c(2,.6,0),
     cex.axis = 1.2) 
segments(0,0,0,17,lty=2) 
abline(h=6.5,  lwd = 4, col="gray")
abline(h=4.5,  lwd = 4, col="gray")
abline(h=2.5,  lwd = 4, col="gray")

```
